package tezhongbing;

import org.junit.Assert;
import org.junit.Test;

/**
 * 两个数值进行交换
 * @author sunniwell
 *
 */
public class ExchangeTest {
	private int a = 15;
	private int b = 78;
	
	@Test
	public void test1(){
		int t = a;
		a = b;
		b = t;
		Assert.assertSame(a, 78);
		Assert.assertSame(b, 15);
	}
	
	@Test
	public void test2(){
		a = a + b;
		b = a - b;
		a = a - b;
		Assert.assertSame(a, 78);
		Assert.assertSame(b, 15);
	}
	
	@Test
	public void test3(){
		a = a ^ b;
		b = a ^ b;
		a = a ^ b;
		Assert.assertSame(a, 78);
		Assert.assertSame(b, 15);
	}
}
